{% extends "blog/base.html" %}
{% load blog_tags %}

{% block title%}{{ post.title }}{% endblock %}

{% block content %}
    <div class="post-detail">
    <div class="post-list">
    <div class="title">{{ post.title }}</div>
    <div class="date">
        {{ post.publish }} by {{ post.author }}
        <a href="{% url "blog:post_share" post.id %}">
            <span class="glyphicon glyphicon-share"></span>分享给好友
        </a>
    </div>
    <div class="post-body">
    {{ post.body|markdown }}
             <div class="tags">
{#                Tags:#}
                {% for tag in post.tags.all %}
                    <a href="{% url "blog:post_list_by_tag" tag.slug %}">
                        <span class="label label-default ">
                            {{ tag.name }}
                        </span>
                    </a>
                    {% if not forloop.last %} &nbsp {% endif %}
                {% endfor %}
            </div>
    </div>

    <h1 class="widget-title">
        关联文章：

    {% for post in similar_posts %}
        <span class="label label-danger">
            <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
        </span>
        {% if not forloop.last %} &nbsp {% endif %}
    {% empty %}
        没有相关联的文章
    {% endfor %}
    </h1>
    <h1 class="comment-list">
{#    {% with comments.count as total_comment %}#}
{#        <p>#}
            评论列表：<span class="badge">{{ comments.count }}</span>
{#            {{ total_comment }} comment{{ total_comment|pluralize }}#}
{#        </p>#}
{#    {% endwith %}#}
    </h1>
    <div class="comment">
    {% for comment in comments %}
        <div class="comment-detail">
            <p class="comment-name">
                <span class="label label-success">
                    {{ comment.name }}
                </span>
            </p>
            <h2 class="comment-body">{{ comment.body|linebreaks }}</h2>
            <h1 class="widget-title">{{ comment.created }}</h1>
        </div>
    {% empty %}
        <p class="comment-none">There are no comments yet.</p>
    {% endfor %}
    {% if new_comment %}
        <p>Your comment has been added.</p>
    {% else %}
        <h2 class="comment-body">发表评论</h2>
        <form action="." method="post" class="form-horizontal" role="form">
{#            {{ comment_form.as_p }}#}
            <div class="form-group form-group-sm">
{#                <label class="col-sm-1 control-label" for="formGroupInputLarge">Name:</label>#}
                <div class="col-lg-12">
                    <input type="text" class="form-control" placeholder="Name" name="name" required/>
                </div>
            </div>
            <div class="form-group form-group-sm">
{#                <label class="col-sm-1 control-label" for="formGroupInputLarge">Email:</label>#}
                <div class="col-lg-12">
                    <input type="email"  class="form-control" placeholder="Email" name="email" required/>
                </div>
            </div>
            <div class="form-group ">
                <div class="col-lg-12">
                    <textarea rows="3" class="form-control" placeholder="Comment" name="body" required></textarea>
                </div>
            </div>

            {% csrf_token %}
{#            <p><input type="submit" value="Add comment"></p>#}
            <button type="submit" class="btn btn-default" >Post Comment</button>

        </form>
    {% endif %}

    </div>
    </div>
        <h1 class="copyright">Welcome to visit my website © Pyx</h1>
    </div>

{% endblock %}